var ContactForm = new Object({
	qnty_elem : 'contacts_qnty',
	addContactForm : function()
	{
		var contacts_qnty = $('#'+this.qnty_elem).attr("value");
		var qnty_elem = this.qnty_elem;
		action='addContactForm';
		// Create new JsHttpRequest object.
	    var req = new JsHttpRequest();
	    
	    // Code automatically called on load finishing.
	    req.onreadystatechange = function() {
	        if (req.readyState == 4) {
	            //get errors from backend
	            if(req.responseText)
	            {
	                alert(req.responseText);
	            }
				//get data from backend		
	            if (req.responseJS.output)
	            {
				    contacts_qnty++;
	            	$("#contacts").append(req.responseJS.output);
					$('#'+qnty_elem).attr("value",contacts_qnty);
	            }
			}
	    }
	    try_add_new_contact = contacts_qnty;try_add_new_contact++;
	    // Prepare request object (automatically choose GET or POST).
	    req.open(null, PathToAjaxBackend, true);
		req.send({contacts_qnty:try_add_new_contact,action:action});
	},
	remContactForm : function()
	{
		var qnty_elem = this.qnty_elem;
		var contacts_qnty = $('#'+this.qnty_elem).attr("value");
	    if(contacts_qnty > 0)
	    {
	        $("#contact_"+contacts_qnty).remove();
	    	contacts_qnty--;
	        $('#'+qnty_elem).attr("value",contacts_qnty);
	    }
	    else return false;
	}
})